package il.ac.braude.sona.gui.forms.questions;

import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
/**
 * Class in charge of check-boxes
 * @author  Ofek Ron
 * @author Avihay Avitan
 * @author Nitzan Inbar
 * @author Sasha Rozenthal
 * Laboratory in Software Engineering,Ort Braude College.</p>
 *
 */
@SuppressWarnings("serial")
public class QCheckBox extends FormQuestion {

	private JCheckBox mCheckBox;
 /*
  * Makes check-box visible.
  */
	public QCheckBox(String string) {
		super(BoxLayout.X_AXIS);
		mCheckBox = new JCheckBox(string);
		mCheckBox.setOpaque(false);
		mCheckBox.setName(string);
		add(mCheckBox);
	}
	@Override
	public void setDefaultAnswer(Object defaultAnswer) {
		mCheckBox.setSelected((Boolean)defaultAnswer);
	}
	@Override
	public Object getAnswer() {
		if( mCheckBox.isSelected())
			return (mCheckBox.getName());
		return null;
	}

}
